<template>
  <h1>{{ sum }}</h1>
  <button @click="sum++">点我++</button>
  <hr />
  <h1>姓名：{{ name }}</h1>
  <h1>年龄：{{ age }}</h1>
  <h1>薪资：{{ job.j1.salary }}w</h1>
  <button @click="name += '~'">增加波浪线</button>
  <button @click="age++">增长年龄</button>
  <button @click="job.j1.salary++">加薪</button>
</template>

<script>
import { reactive, toRefs, ref, readonly, shallowReadonly } from "vue";

export default {
  name: "Demo",
  setup() {
    let sum = ref(0);

    let person = reactive({
      name: "李文泰",
      age: 20,
      job: {
        j1: {
          salary: "20",
        },
      },
    });

    // person = readonly(person);
    person = shallowReadonly(person);

    //返回对象
    return { sum, ...toRefs(person) };
  },
};
</script>

<style>
</style>
